package com.qezhhnjy.mall.member.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.member.MemberStatisticsInfo;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.member.service.MemberStatisticsInfoService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 会员统计信息 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "会员统计信息接口")
@Slf4j
@RequestMapping("/member-statistics-info")
public class MemberStatisticsInfoController {
    @Resource
    private MemberStatisticsInfoService memberStatisticsInfoService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取会员统计信息信息")
    public BaseResult<MemberStatisticsInfo> get(Long id) {
        MemberStatisticsInfo memberStatisticsInfo = memberStatisticsInfoService.getById(id);
        return BaseResult.success(memberStatisticsInfo);
    }

    @PostMapping("/save")
    @Operation(summary = "新增会员统计信息信息")
    public BaseResult<MemberStatisticsInfo> save(@RequestBody MemberStatisticsInfo memberStatisticsInfo) {
        memberStatisticsInfoService.save(memberStatisticsInfo);
        return BaseResult.success(memberStatisticsInfo);
    }

    @PutMapping("/update")
    @Operation(summary = "更新会员统计信息信息")
    public BaseResult<MemberStatisticsInfo> update(@RequestBody MemberStatisticsInfo memberStatisticsInfo) {
        memberStatisticsInfoService.updateById(memberStatisticsInfo);
        return BaseResult.success(memberStatisticsInfo);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取会员统计信息信息")
    public BaseResult<Page<MemberStatisticsInfo>> page(@RequestBody Page<MemberStatisticsInfo> page) {
        memberStatisticsInfoService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除会员统计信息信息")
    public BaseResult<Long> delete(Long id) {
        memberStatisticsInfoService.removeById(id);
        return BaseResult.success(id);
    }
}

